<template>
  <div class="wrapper">
    <el-row>
      <el-col :span="24">
        <div class="header">
          <img class="sculpture" src="../../../../assets/images/head.png" alt />
          <span class="welcome">
            <font size="4" face="宋体">
              <strong>{{ userInfo.realname }}：您好！欢迎进入项目申报</strong>
            </font>
          </span>
          <!-- <img class="backico" src="../../../../assets/images/backico.png" @click="back()"/> -->
          <el-button
            size="small"
            round
            style="background-image: linear-gradient(#e9f0e9, white);float:right; margin: 2px 50px 0 0;"
            @click="back()"
            >返 回</el-button
          >
        </div>
      </el-col>
    </el-row>
    <div class="formall">
      <el-row>
        <el-col :span="24">
          <div class="title">
            <font size="4.7" face="微软雅黑">
              <strong>项目申报基本信息表</strong>
            </font>
          </div>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form
            style="padding-left:180px"
            :model="form"
            size="medium"
            :rules="rules"
            ref="form"
            label-width="100px"
            class="demo-ruleForm"
          >
            <el-row>
            <el-col :span="18">
              <el-form-item label="课题名称" prop="title">
                <el-input
                  class="cell-width"
                  v-model="form.title"
                  prefix-icon="el-icon-postcard"
                  placeholder="请勿超过100个汉字"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="7">
              <el-form-item label="研究方向" prop="research_direction">
                <el-input
                  class="cell-width"
                  v-model="form.research_direction"
                  prefix-icon="el-icon-rank"
                  placeholder="请输入研究方向"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="7">
              <el-form-item label="主题词" prop="theme">
                <el-input
                  class="cell-width"
                  v-model="form.theme"
                  prefix-icon="el-icon-attract"
                  placeholder="请输入主题词，以分号隔开（至多四个）"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="7">
              <el-form-item label="完成时间" prop="finish_time">
                <el-date-picker
                  class="cell-width"
                  type="date"
                  placeholder="选择日期（计划完成时间）"
                  v-model="form.finish_time"
                ></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="7">
              <el-form-item label="字数" prop="word_count">
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="以万字为单位"
                  placement="top-start"
                >
                  <el-input
                    style="width: 70%"
                    v-model="form.word_count"
                    prefix-icon="el-icon-document-copy"
                    placeholder="请输入最终成果字数"
                  ></el-input>
                </el-tooltip>
                <span>
                  <strong>(万字)</strong>
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="7">
              <el-form-item label="工作单位" prop="unit">
                <el-input
                  class="cell-width"
                  v-model="form.unit"
                  prefix-icon="el-icon-school"
                  placeholder="请按单位和部门公章填写全称"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="7">
              <el-form-item label="通讯地址" prop="postal_address">
                <el-input
                  class="cell-width"
                  v-model="form.postal_address"
                  prefix-icon="el-icon-discount"
                  placeholder="请按地区名，街道名及门牌号码填写"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="7">
              <el-form-item label="邮政编码" prop="post_code">
                <el-input
                  class="cell-width"
                  v-model.number="form.post_code"
                  prefix-icon="el-icon-map-location"
                  placeholder="请填写邮编（可不填）"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="21">
              <el-tooltip
                class="item"
                effect="dark"
                content="至少勾选一项至多两项"
                placement="top-start"
              >
                <el-form-item label="预计成果形式" prop="result">
                  <el-checkbox-group
                    style="width:100%"
                    v-model="result"
                    :min="1"
                    :max="2"
                    :change="handleChange()"
                  >
                    <el-checkbox
                      v-for="item in options2"
                      :key="item.value"
                      :label="item.title"
                      :value="item.id"
                    > </el-checkbox>
                  </el-checkbox-group>
                </el-form-item>
              </el-tooltip>
            </el-col>
            <el-col :span="7">
              <el-form-item label="项目资助类别申请" prop="train_support">
                <el-select
                  class="cell-width"
                  v-model="form.train_support"
                >
                  <el-option
                    v-for="item in options1"
                    :key="item.value"
                    :label="item.title"
                    :value="item.id"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="是否同意进行类别调剂：" prop="train_support_tj">
                <template>
                  <el-radio v-model="form.train_support_tj" label="1">调剂</el-radio>
                  <el-radio v-model="form.train_support_tj" label="2">不调剂</el-radio>
                </template>
              </el-form-item>
            </el-col>
            <el-col :span="21">
              <el-form-item label="主要参加者" prop="major_peoples">
                <el-input
                  style="width: 50%;"
                  :disabled="true"
                  v-model="form.major_peoples"
                  prefix-icon="el-icon-user-solid"
                  placeholder="此处只显示添加的参加者姓名，具体添加个人信息请点击右边按钮"
                ></el-input>
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="点击添加人员信息"
                  placement="top-start"
                >
                  <el-button
                    style="margin-left:15px"
                    type="primary"
                    icon="el-icon-plus"
                    @click="dialogFormVisible = true"
                    circle
                  ></el-button>
                </el-tooltip>
                <el-dialog
                  width="35%"
                  title="完善人员信息"
                  :visible.sync="dialogFormVisible"
                >
                  <el-form :model="formPer" ref="formPer" :rules="rulesOne">
                    <table class="content" border cellspacing="0">
                      <tr>
                        <td class="left"><span class="red">*</span>姓名</td>
                        <td class="right">
                          <el-input
                            type="text"
                            placeholder="参与人员的姓名，请认真填写"
                            v-model="formPer.name"
                            clearable
                          ></el-input>
                        </td>
                      </tr>
                      <tr>
                        <td class="left"><span class="red">*</span>性别</td>
                        <td class="right">
                          <el-select v-model="formPer.sex">
                            <el-option
                              v-for="item in options"
                              :key="item.value"
                              :label="item.label"
                              :value="item.value">
                            </el-option>
                          </el-select>
                        </td>
                      </tr>
                      <tr>
                        <td class="left"><span class="red">*</span>身份证号</td>
                        <td class="right">
                          <el-input
                            type="text"
                            placeholder="请按照身份证号格式输入"
                            v-model="formPer.idnumber"
                            clearable
                          ></el-input>
                        </td>
                      </tr>
                       <tr>
                        <td class="left"><span class="red">*</span>手机号</td>
                        <td class="right">
                          <el-input type="text" placeholder="请输入正确手机号" v-model="formPer.phone" clearable></el-input>
                        </td>
                      </tr>
                      <tr>
                        <td class="left"><span class="red">*</span>职称</td>
                        <td class="right">
                          <el-input
                            type="text"
                            placeholder="请输入职称名称"
                            v-model="formPer.jobrank"
                            clearable
                          ></el-input>
                        </td>
                      </tr>
                      <tr>
                        <td class="left"><span class="red">*</span>职务(身份)</td>
                        <td class="right">
                          <el-input
                            type="text"
                            placeholder="请输入职务名称"
                            v-model="formPer.work"
                            clearable
                          ></el-input>
                        </td>
                      </tr>
                      <tr>
                        <td class="left"><span class="red">*</span>研究专长</td>
                        <td class="right">
                          <el-input
                            type="text"
                            placeholder="请输入研究专长"
                            v-model="formPer.expertise"
                            clearable
                          ></el-input>
                        </td>
                      </tr>
                      <tr>
                        <td class="left"><span class="red">*</span>承担任务</td>
                        <td class="right">
                          <el-input
                            type="text"
                            placeholder="请输入承担任务"
                            v-model="formPer.task"
                            clearable
                          ></el-input>
                        </td>
                      </tr>
                      <tr>
                        <td class="left"><span class="red">*</span>学历</td>
                        <td class="right">
                          <el-select
                            type="text"
                            placeholder="请选择学历"
                            v-model="formPer.edu"
                            clearable
                          >
                            <el-option
                              v-for="item in edus"
                              :key="item.value"
                              :label="item.label"
                              :value="item.label"
                            ></el-option>
                          </el-select>
                        </td>
                      </tr>
                      <tr>
                        <td class="left"><span class="red">*</span>学位</td>
                        <td class="right">
                          <el-select
                            type="text"
                            placeholder="请选择学位"
                            v-model="formPer.degree"
                            clearable
                          >
                            <el-option
                              v-for="item in degrees"
                              :key="item.value"
                              :label="item.label"
                              :value="item.label"
                            ></el-option>
                          </el-select>
                        </td>
                      </tr>
                      <tr>
                        <td class="left"><span class="red">*</span>工作单位</td>
                        <td class="right">
                          <el-input
                            type="text"
                            placeholder="请按单位和部门公章填写全称"
                            v-model="formPer.unit"
                            clearable
                          ></el-input>
                        </td>
                      </tr>
                    </table>
                  </el-form>
                  <div slot="footer" class="dialog-footer">
                    <el-button @click="dialogFormVisible = false"
                      >取 消</el-button
                    >
                    <el-button
                      type="primary"
                      @click="
                        dialogFormVisible = false
                        servePer(formPer, 'formPer')
                      "
                      >确 定</el-button
                    >
                  </div>
                </el-dialog>
              </el-form-item>
            </el-col>
            </el-row>
            <el-col :span="21" class="apply_expense">经费申请</el-col>
            <el-row>
            <el-col :span="7">
              <el-form-item label="书本费" prop="book_fee">
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="以“万元”为单位填写数字"
                  placement="top-start"
                >
                  <el-input
                    class="expense-width"
                    oninput="value=value.replace(/[^\d.]/g,'')"
                    v-model="form.book_fee"
                    placeholder="若无请填0"
                  ></el-input>
                </el-tooltip>
                <span>
                  <strong>(万元)</strong>
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="15">
              <el-form-item label="依据及用途" prop="book_fee_basis">
                <el-input
                  class="cell-width"
                  v-model="form.book_fee_basis"
                  placeholder="请输入书本费预算的依据及用途，空缺项要填“无”，下同"
                  type="textarea"
                  maxlength="200"
                  show-word-limit
                  autosize
                ></el-input>
              </el-form-item>
            </el-col>
            </el-row>
            <el-row>
            <el-col :span="7">
              <el-form-item label="数据采集费" prop="data_fee">
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="以“万元”为单位填写数字"
                  placement="top-start"
                >
                  <el-input
                    class="expense-width"
                    oninput="value=value.replace(/[^\d.]/g, '')"
                    v-model="form.data_fee"
                    placeholder="若无请填0"
                  ></el-input>
                </el-tooltip>
                <span>
                  <strong>(万元)</strong>
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="15">
              <el-form-item label="依据及用途" prop="book_fee_basis">
                <el-input
                  class="cell-width"
                  type="textarea"
                  autosize
                  v-model="form.data_fee_basis"
                  placeholder="请输入数据采集费预算的依据及用途"
                  maxlength="200"
                  show-word-limit
                ></el-input>
              </el-form-item>
            </el-col>
            </el-row>
            <el-row>
            <el-col :span="7">
              <el-form-item label="差旅费" prop="travel_fee">
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="以“万元”为单位填写数字"
                  placement="top-start"
                >
                  <el-input
                    class="expense-width"
                    oninput="value=value.replace(/[^\d.]/g, '')"
                    v-model="form.travel_fee"
                    placeholder="若无请填0"
                  ></el-input>
                </el-tooltip>
                <span>
                  <strong>(万元)</strong>
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="15">
              <el-form-item label="依据及用途" prop="travel_fee_basis">
                <el-input
                  class="cell-width"
                  type="textarea"
                  autosize
                  v-model="form.travel_fee_basis"
                  placeholder="请输入差旅费预算的依据及用途"
                  maxlength="200"
                  show-word-limit
                ></el-input>
              </el-form-item>
            </el-col>
            </el-row>
            <el-row>
            <el-col :span="7">
              <el-form-item label="会议费" prop="meeting_fee">
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="以“万元”为单位填写数字"
                  placement="top-start"
                >
                  <el-input
                    class="expense-width"
                    oninput="value=value.replace(/[^\d.]/g, '')"
                    v-model="form.meeting_fee"
                    placeholder="若无请填0"
                  ></el-input>
                </el-tooltip>
                <span>
                  <strong>(万元)</strong>
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="15">
              <el-form-item label="依据及用途" prop="meeting_fee_basis">
                <el-input
                  class="cell-width"
                  type="textarea"
                  autosize
                  v-model="form.meeting_fee_basis"
                  placeholder="请输入会议费预算的依据及用途"
                  maxlength="200"
                  show-word-limit
                ></el-input>
              </el-form-item>
            </el-col>
            </el-row>
            <el-row>
            <el-col :span="7">
              <el-form-item label="国际合作费" prop="international_fee">
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="以“万元”为单位填写数字"
                  placement="top-start"
                >
                  <el-input
                    class="expense-width"
                    oninput="value=value.replace(/[^\d.]/g, '')"
                    v-model="form.international_fee"
                    placeholder="若无请填0"
                  ></el-input>
                </el-tooltip>
                <span>
                  <strong>(万元)</strong>
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="15">
              <el-form-item label="依据及用途" prop="international_fee_basis">
                <el-input
                  class="cell-width"
                  type="textarea"
                  autosize
                  v-model="form.international_fee_basis"
                  placeholder="请输入国际交流合作费预算的依据及用途"
                  maxlength="200"
                  show-word-limit
                ></el-input>
              </el-form-item>
            </el-col>
            </el-row>
            <el-row>
            <el-col :span="7">
              <el-form-item label="设备费" prop="equipment_fee">
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="以“万元”为单位填写数字"
                  placement="top-start"
                >
                  <el-input
                    class="expense-width"
                    oninput="value=value.replace(/[^\d.]/g, '')"
                    v-model="form.equipment_fee"
                    placeholder="若无请填0"
                  ></el-input>
                </el-tooltip>
                <span>
                  <strong>(万元)</strong>
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="15">
              <el-form-item label="依据及用途" prop="equipment_fee_basis">
                <el-input
                  class="cell-width"
                  type="textarea"
                  autosize
                  v-model="form.equipment_fee_basis"
                  placeholder="请输入设备费预算的依据及用途"
                  maxlength="200"
                  show-word-limit
                ></el-input>
              </el-form-item>
            </el-col>
            </el-row>
            <el-row>
            <el-col :span="7">
              <el-form-item label="专家咨询费" prop="consulting_fee">
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="以“万元”为单位填写数字"
                  placement="top-start"
                >
                  <el-input
                    class="expense-width"
                    oninput="value=value.replace(/[^\d.]/g, '')"
                    v-model="form.consulting_fee"
                    placeholder="若无请填0"
                  ></el-input>
                </el-tooltip>
                <span>
                  <strong>(万元)</strong>
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="15">
              <el-form-item label="依据及用途" prop="consulting_fee_basis">
                <el-input
                  class="cell-width"
                  type="textarea"
                  autosize
                  v-model="form.consulting_fee_basis"
                  placeholder="请输入专家咨询费预算的依据及用途"
                  maxlength="200"
                  show-word-limit
                ></el-input>
              </el-form-item>
            </el-col>
            </el-row>
            <el-row>
            <el-col :span="7">
              <el-form-item label="劳务费" prop="labour_fee">
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="以“万元”为单位填写数字"
                  placement="top-start"
                >
                  <el-input
                    class="expense-width"
                    oninput="value=value.replace(/[^\d.]/g, '')"
                    v-model="form.labour_fee"
                    placeholder="若无请填0"
                  ></el-input>
                </el-tooltip>
                <span>
                  <strong>(万元)</strong>
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="15">
              <el-form-item label="依据及用途" prop="labour_fee_basis">
                <el-input
                  class="cell-width"
                  type="textarea"
                  autosize
                  v-model="form.labour_fee_basis"
                  placeholder="请输入劳务费预算的依据及用途"
                  maxlength="200"
                  show-word-limit
                ></el-input>
              </el-form-item>
            </el-col>
            </el-row>
            <el-row>
            <el-col :span="7">
              <el-form-item label="印刷费" prop="print_fee">
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="以“万元”为单位填写数字"
                  placement="top-start"
                >
                  <el-input
                    class="expense-width"
                    oninput="value=value.replace(/[^\d.]/g, '')"
                    v-model="form.print_fee"
                    placeholder="若无请填0"
                  ></el-input>
                </el-tooltip>
                <span>
                  <strong>(万元)</strong>
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="15">
              <el-form-item label="依据及用途" prop="book_fee_basis">
                <el-input
                  class="cell-width"
                  type="textarea"
                  autosize
                  v-model="form.print_fee_basis"
                  placeholder="请输入印刷费预算的依据及用途"
                  maxlength="200"
                  show-word-limit
                ></el-input>
              </el-form-item>
            </el-col>
            </el-row>
            <el-row>
            <el-col :span="7">
              <el-form-item label="管理费" prop="administration_fee">
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="以“万元”为单位填写数字"
                  placement="top-start"
                >
                  <el-input
                    class="expense-width"
                    oninput="value=value.replace(/[^\d.]/g, '')"
                    v-model="form.administration_fee"
                    placeholder="若无请填0"
                  ></el-input>
                </el-tooltip>
                <span>
                  <strong>(万元)</strong>
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="15">
              <el-form-item label="依据及用途" prop="administration_fee_basis">
                <el-input
                  class="cell-width"
                  type="textarea"
                  autosize
                  v-model="form.administration_fee_basis"
                  placeholder="请输入管理费预算的依据及用途"
                  maxlength="200"
                  show-word-limit
                ></el-input>
              </el-form-item>
            </el-col>
            </el-row>
            <el-row>
            <el-col :span="7">
              <el-form-item label="其他支出" prop="other_fee">
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="以“万元”为单位填写数字"
                  placement="top-start"
                >
                  <el-input
                    class="expense-width"
                    oninput="value=value.replace(/[^\d.]/g, '')"
                    v-model="form.other_fee"
                    placeholder="若无请填0"
                  ></el-input>
                </el-tooltip>
                <span>
                  <strong>(万元)</strong>
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="15">
              <el-form-item label="依据及用途" prop="other_fee_basis">
                <el-input
                  class="cell-width"
                  type="textarea"
                  autosize
                  v-model="form.other_fee_basis"
                  placeholder="请输入其他支出预算的依据及用途"
                  maxlength="200"
                  show-word-limit
                ></el-input>
              </el-form-item>
            </el-col>
            </el-row>
            <el-row>
              <el-col :span="7">
                <el-form-item label="合计:" prop="all_fee">
                {{all_fee}}
                <span>
                  <strong>(万元)</strong>
                </span>
              </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </el-col>
      </el-row>
      <el-col :span="24" class="apply_expense">项目背景</el-col>
      <el-row>
        <el-col :span="22" >  
         <!--  实践育人 -->
          <div style="margin-left: 10%;"  >
              <UE
              :config="config"
              v-model="background"
              ref="ue1"
              :id="ue1"
              :defaultMsg="defaultMsg"
            ></UE>
          </div> 
        </el-col>
      </el-row>
      <el-col :span="24" class="apply_expense">项目简介（限500字以内）</el-col>
      <el-row>
        <el-col :span="22">
          <div style="margin-left: 10%;">
            <UE
              v-model="introduction"
              :config="config"
              ref="ue2"
              :id="ue2"
              :defaultMsg="defaultMsg1"
            ></UE>
          </div> 
        </el-col>
      </el-row>
      <el-col :span="24" class="apply_expense">项目方案（限5000字以内）</el-col>
      <el-row>
        <el-col :span="22">
          <div style="margin-left:10%;">
            <UE
              v-model="plan"
              :config="config1"
              ref="ue3"
              :id="ue3"
              :defaultMsg="defaultMsg2"
            ></UE>
          </div> 
        </el-col>
      </el-row>
      <el-col :span="24" class="apply_expense">学校提供条件</el-col>
      <el-row>
        <el-col :span="22">
          <div style="margin-left: 10%;">
            <UE
              v-model="schsupport"
              :config="config"
              ref="ue4"
              :id="ue4"
              :defaultMsg="defaultMsg3"
            ></UE>
           <!-- </el-input> -->
          </div> 
        </el-col>
      </el-row>
      <el-col :span="24" class="apply_expense">预期成果</el-col>
      <el-row>
        <el-col :span="22">
          <div style="margin-left: 10%;">
            <UE
              v-model="result_1"
              :config="config"
              ref="ue5"
              :id="ue5"
              :defaultMsg="defaultMsg4"
            ></UE>
          </div> 
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="7">
          <p style="margin-top:10%;margin-left:35%;">附件上传:</p>
        </el-col>
        <el-col :span="7" >
          <div style="margin-left: -40%;margin-top: 8%;">
            <el-upload
              class="upload-demo"
              action="http://8.142.34.26:8097/php/index.php/admin/Upload/SupportInput"
              :data="{pid: '2'}"
              :on-preview="handlePreview"
              :on-remove="handleRemove"
              :on-success="handleSuccess"
              :before-remove="beforeRemove"
              multiple
              :limit="3"
              :on-exceed="handleExceed"
              :file-list="fileList">
              <el-button size="small" type="primary">点击上传</el-button>
              <div slot="tip" class="el-upload__tip">只能zip/rar上传文件，且不超过100MB</div>

            <!--   <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">上传到服务器</el-button> -->
              </el-upload>
            </div>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <div class="holder">
            <el-button type style="background-color: #eef6fd" @click="cancel()"
              >取 消</el-button
            >
            <el-button type="primary" class="btn2" @click="submitAll('form')"
              >提 交</el-button
            >
          </div>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
import http from '../../../../assets/js/http.js'
import UE from '../../../ue.vue'

export default {
  // props: {},
  data() {
    var checkPostcode = (rule, value, callback) => {
      // console.log(value)
      if (value) {
        setTimeout(() => {
          if (!Number.isInteger(value)) {
            callback(new Error('请输入数字'))
          } else {
            callback()
          }
        }, 1000)
      }else{
        callback()
      }
    }
    return {
       fileList: [],
      // formData: new FormData(),
      // file: {}, //文件数据  
      dataObj:{
        pid: 1
      },
      ue1:'ue1',
      ue2:'ue2',
      ue3:'ue3',
      ue4:'ue4',
      ue5:'ue5',
      defaultMsg:'项目的意义、项目已有的基础，与本项目有关的工作积累和已取得的成绩等',
      defaultMsg3:'项目开展所需的智力支持、条件保障、实验实训情况、配套经费、扶持政策等',
      defaultMsg1: '请输入项目简介',
      defaultMsg5: '请输入项目背景',
      defaultMsg2: '基本内容应包括项目主题与思路、项目背景（意义、基础等）、学科（理论）支撑、实施方法与过程、主要成效及经验、下一步计划安排等，要求文字简洁、重点突出，字数5000字以内。',
      defaultMsg4: '成果形态包括出版物（著作、论文、画册、经验感悟集等）、调研报告、获奖证书（师生、项目等）、采纳证明（成果被机构或单位采纳运用）、新闻报道（微信公众号、新闻网站、报纸）等',
      config: {
        initialFrameWidth: '100%',
        initialFrameHeight: 150,
        maximumWords:500
      },
      config1: {
        initialFrameWidth: '100%',
        initialFrameHeight: 150,
        maximumWords:5000
      },
      introduction: "", //项目简介
      result_1: "", //预期成果
      schsupport: "", //学校提供条件
      plan: "", //
      background: "",
      userInfo: Lockr.get('userInfo'),
      parent: this.$route.params.parent,
      dialogFormVisible: false,
      dialogTableVisible: false,
      options1: [],
      options2: [],
      options: [
        { 
          label: '男',
          value: 1
        },
        { label: '女',
          value: 2
        }],
      edus: [
        {
          label: '博士研究生',
          value: '1'
        },
        {
          label: '硕士研究生',
          value: '2'
        },
        {
          label: '大学本科',
          value: '3'
        },
        {
          label: '大学专科',
          value: '4'
        },
        {
          label: '高中',
          value: '5'
        },
        {
          label: '其他',
          value: '6'
        }
      ],
      degrees: [
        {
          label: '博士',
          value: '1'
        },
        {
          label: '硕士',
          value: '2'
        },
        {
          label: '学士',
          value: '3'
        },
        {
          label: '其他',
          value: '4'
        }
      ],
      form: {
        file_id:'',
        train_support_tj: '',
        title: '',
        train_support: '',
        research_direction: '',
        theme: '',
        result: [,],
        finish_time: '',
        word_count: '',
        unit: '',
        postal_address: '',
        post_code: '',
        major_peoples: '',
        book_fee: '',
        book_fee_basis: '',
        data_fee: '',
        data_fee_basis: '',
        travel_fee: '',
        travel_fee_basis: '',
        international_fee: '',
        international_fee_basis: '',
        labour_fee: '',
        labour_fee_basis: '',
        administration_fee: '',
        administration_fee_basis: '',
        print_fee: '',
        print_fee_basis: '',
        equipment_fee: '',
        equipment_fee_basis: '',
        consulting_fee: '',
        consulting_fee_basis: '',
        meeting_fee: '',
        meeting_fee_basis: '',
        other_fee: '',
        other_fee_basis: '',
      },
      formPer: {
        work: '',
        name: '',
        sex: '',
        idnumber: '',
        task: '',
        phone: '',
        jobrank: '',
        expertise: '',
        edu: '',
        degree: '',
        unit: ''
      },
      file_id:'',
      result:[],
      permsgAll: [],
      permsg: {},
      rules: {
        title: [
          {
            required: true,
            message: '请输入课题名称(1-100个字符)',
            trigger: 'blur'
          },
          { min: 1, max: 100, message: '长度在 1 到 100 个字符', trigger: 'blur' }
        ],
        research_direction: [
          { required: true, message: '请输入研究方向', trigger: 'change' }
        ],
        train_support: [
          { required: true, message: '请输入项目申报类型', trigger: 'change' }
        ],
         train_support_tj: [
          { required: true, message: '请选择是否进行调剂', trigger: 'change' }
        ],
        theme: [
          {
            required: true,
            message: '请输入1-4个主题词，分号隔开',
            trigger: 'change'
          }
        ],
        finish_time: [
          { required: true, message: '请选择日期', trigger: 'change' }
        ],
        word_count: [
          {
            required: true,
            message: '请填写字数',
            trigger: 'change'
          }
        ],
        unit: [
          { required: true, message: '请填写工作单位', trigger: 'change' }
        ],
        result: [
        {
           type: 'array',required: true, message: '请至少选择一个预计成果形式', trigger: 'change'
        }],
        postal_address: [
          { required: true, message: '请填写通讯地址', trigger: 'change' }
        ],
        post_code: [{ validator: checkPostcode, trigger: 'blur' }],
        // major_peoples: [
        //   {
        //     required: true,
        //     message: '请点击右边按钮添加人员',
        //     trigger: 'change'
        //   }
        // ],
        book_fee: [
          {
            // type: 'number',
            required: true,
            message: '若无请填0',
            trigger: 'change'
          }
        ],
        data_fee: [
          {
            // type: 'number',
            required: true,
            message: '若无请填0',
            trigger: 'change'
          }
        ],
        travel_fee: [
          {
            // type: 'number',
            required: true,
            message: '若无请填0',
            trigger: 'change'
          }
        ],
        international_fee: [
          {
            // type: 'number',
            required: true,
            message: '若无请填0',
            trigger: 'change'
          }
        ],
        labour_fee: [
          {
            // type: 'number',
            required: true,
            message: '若无请填0',
            trigger: 'change'
          }
        ],
        administration_fee: [
          {
            // type: 'number',
            required: true,
            message: '若无请填0',
            trigger: 'change'
          }
        ],
        print_fee: [
          {
            // type: 'number',
            required: true,
            message: '若无请填0',
            trigger: 'change'
          }
        ],
        equipment_fee: [
          {
            // type: 'number',
            required: true,
            message: '若无请填0',
            trigger: 'change'
          }
        ],
        consulting_fee: [
          {
            // type: 'number',
            required: true,
            message: '若无请填0',
            trigger: 'change'
          }
        ],
        meeting_fee: [
          {
            // type: 'number',
            required: true,
            message: '若无请填0',
            trigger: 'change'
          }
        ],
        other_fee: [
          {
            // type: 'number',
            required: true,
            message: '若无请填0',
            trigger: 'change'
          }
        ]
      }
    }
  },
  methods: {
      handleRemove(file, fileList) {
        console.log(file, fileList);
      },
      handlePreview(file) {
        console.log(file);
      },
      handleExceed(files, fileList) {
        this.$message.warning(`当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
      },
      beforeRemove(file, fileList) {
        return this.$confirm(`确定移除 ${ file.name }？`);
      },
    handleRemove(file, fileList) {
        console.log(file, fileList);
      },
      handlePreview(file) {
        console.log(file);
      },
      handleChange(){
        console.log(this.result)
        // this.form.result=this.result
      },
      handleSuccess(response, file, fileList) {
        console.log(response);
        if(response.code == 200){
          // console.log(response.data)
          this.file_id = response.data.file_id 
          // console.log(response.data.file_id)
        }else{
          _g.toastMsg('error',response.error)
        }
        
      },
      handleExceed(files, fileList) {
        this.$message.warning(`当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
      },
      beforeRemove(file, fileList) {
        return this.$confirm(`确定移除 ${ file.name }？`);
      },
    // 初始化函数
    init() {
      //console.log(this.userInfo)
      this.getSelection()
    },
    // 获取下拉框
    getSelection() {
      let data = {}
      this.apiPost('admin/Report/DropdowmList', data).then(res => {
        this.handelResponse(res, data => {
          console.log(data.achievements)
          this.options1 = data.support
          this.options2 = data.achievements
        })
      })
    },
    // UESet() {
    //   window.UE.Editor.prototype.placeholder = function(justPlainText) {
    //     var _editor = this
    //     _editor.addListener('focus', function() {
    //       var localHtml = _editor.getPlainTxt()
    //       if ($.trim(localHtml) === $.trim(justPlainText)) {
    //         _editor.setContent(' ')
    //       }
    //     })
    //     _editor.addListener('blur', function() {
    //       var localHtml = _editor.getContent()
    //       if (!localHtml) {
    //         _editor.setContent(justPlainText)
    //       }
    //     })
    //     _editor.ready(function() {
    //       _editor.fireEvent('blur')
    //     })
    //   }
    //   // 实例化编辑器example
    //   var editor = window.UE.getEditor('editor')
    //   editor.placeholder(
    //     '主要内容提示：1.内容应由项目主持人撰写；文章内容要层次清楚、观点明晰、用语准确、文风朴实，要有实质性内容，并具有整体性和系统性，不得简单排列篇章目录；成果形式为出版物，或者3000左右文字材料或调研报告，附图片及其他佐证材料复印件或原件，具体依据实际情况确定。2.项目预期研究计划的执行情况；成果研究内容及方法的创新程度、突出特色；成果的创新实践性以及社会影响和效益；成果存在的不足或欠缺，尚需深入研究的问题等。'
    //   )
    // },
    // 多选框选择数据["", ""]格式
    // mulCheck(value) {
    //   console.log(this.result)
    // },
    // 所有参加者信息逐一保存    
    servePer(permsg) {
       console.log(permsg)
      //  this.form.result = this.form.result.join()
      // this.form.result = this.result
      //  console.log(this.form.result)
      var checkResult = this.checkList(permsg, [
        {
          name: 'jobrank',
          reg: ['notnull']
        },
        {
          name: 'name',
          reg: ['notnull']
        },
        {
          name: 'sex',
          reg: ['notnull']
        },
        {
          name: 'idnumber',
          reg: ['notnull']
        },
        {
          name: 'task',
          reg: ['notnull']
        },
        {
          name: 'expertise',
          reg: ['notnull']
        },
        {
          name: 'edu',
          reg: ['notnull']
        },
        {
          name: 'degree',
          reg: ['notnull']
        },
        {
          name: 'unit',
          reg: ['notnull']
        },
        {
          name: 'work',
          reg: ['notnull']
        }
      ])
      // console.log(checkResult)
      if (_g.j2s(checkResult) === '{}') {
        this.form.major_peoples = ''
        // 地址指向问题，如果不创建新的对象，每次都会指向同一个对象
        let curList = JSON.parse(JSON.stringify(permsg))
        this.permsgAll.push(curList)
        this.permsgAll.forEach(element => {
          this.form.major_peoples += element.name + ' '
        })
        this.formPer = {}
        _g.toastMsg('success', '添加成功')
      } else {
        _g.toastMsg('warning', '请完善个人信息')
      }
    },
    // 提交所有信息之前的验证
    submitAll(form) {
      // 大表单验证
      console.log(this.result)
      this.form.result = this.result
      // this.form.result = this.result.join()
      console.log(this.form.result)
      // if(this.file_id == ''){
      //   _g.toastMsg('error','请上传附件！')
      // }else{
      //   this.form.file_id = this.file_id
      //   if(this.introduction == '' && this.plan == '' && this.schsupport == '' && this.result_1 == '' && this.background == '') {
      //   _g.toastMsg('error','请填写项目相关材料')
      //   }else{
      //     this.submit()
      //   }    
      // }
      
        this.form.file_id = this.file_id
        if(this.introduction == '' && this.plan == '' && this.schsupport == '' && this.result_1 == '' && this.background == '') {
          
        _g.toastMsg('error','请填写项目相关材料')
        }else{
          this.submit(this.form.result)
        } 
        
    },
    // 右上角返回上一界面
    back() {
      this.$router.push({
        name: 'reproject',
         params: {
          id: this.$route.params.id,
          saveData: this.$route.params.saveData,
          reData: this.$route.params.reData
        }
      })
    },
    // 点击取消按钮当前页面刷新
    cancel() {
      this.$router.go(0)
    },
    // 提交所有信息
    submit(result) {
      this.timeDeal()
      // console.log(result)
      this.form.result=this.result.join(",")
      let data = {
        form: this.form,
        // result:this.result,
        result_1: this.result_1,
        schsupport: this.schsupport,
        plan: this.plan,
        introduction: this.introduction,
        background: this.background,
        partner: this.permsgAll,
        // achievement: this.$refs.ue.getUEContent(),
        username: this.userInfo.username,
        project_id: this.$route.params.id
      }
      console.log(data)
      this.apiPost('admin/Report/TrainWrite', data).then(res => {
        // console.log(res);
        this.handelResponse(res, data => {
          _g.toastMsg('success', '项目申报提交成功')
          router.push({
            name: 'detailpro',
            params: { id: this.$route.params.id }
          })
        })
      })
    },
    // 表单日期格式处理
    timeDeal() {
      let date = new Date(this.form.finish_time)
      let year = date.getFullYear()
      let month = date.getMonth() + 1
      let day = date.getDate()
      if (month < 10) {
        month = '0' + month
      }
      if (day < 10) {
        day = '0' + day
      }
      this.form.finish_time = year + '-' + month + '-' + day
    }
  },
  created() {
    _g.closeGlobalLoading()
    this.init()
   //console.log(this.$route.params.parent)
  },
  watch: {
    form(newForm, oldForm) {
      //console.log(newForm)
    }
  },
  computed: {
    all_fee: function(){
      if(isNaN(this.form.book_fee)&&isNaN(this.form.data_fee)&&isNaN(this.form.travel_fee)&&isNaN(this.form.international_fee)&&isNaN(this.form.equipment_fee)&&isNaN(this.form.consulting_fee)&&NaN(this.form.labour_fee)&&isNaN(this.form.print_fee)&&isNaN(this.form.administration_fee)&&isNaN(this.form.other_fee)&&isNaN(this.form.meeting_fee)){
        return 0
      }else{
        return  parseInt(this.form.book_fee*100 + this.form.data_fee*100 + this.form.travel_fee*100+ this.form.international_fee*100+ this.form.equipment_fee*100+ this.form.consulting_fee*100+ this.form.labour_fee*100+ this.form.print_fee*100+ this.form.administration_fee*100+ this.form.other_fee*100+ this.form.meeting_fee*100)/100  
      }
    }
  },
  components: { UE },
  mounted() {},
  mixins: [http]
}
</script>
<style scoped>
.sculpture {
  height: 30px;
  width: 30px;
}
.backico {
  padding: 8px 20px 0 0;
  float: right;
  height: 20px;
  width: 20px;
}
.header {
  margin-bottom: 10px;
  background-image: linear-gradient(#e9f0e9, white);
}
.welcome {
  padding-left: 10px;
}
.title {
  background-color: #add5fe;
  border-radius: 4px 4px 0 0;
  line-height: 30px;
  margin-bottom: 30px;
}
.formall {
  background: #fff;
}
.cell-width {
  width: 88%;

}
.left {
  width: 200px;
  text-align: right;
  padding-right: 10px;
  font-family: '微软雅黑';
}
.right {
  width: 400px;
  padding: 4px;
}
.red {
  color: red;
  padding-right: 3px;
}
.content {
  border-color: #e8f6f9;
}
.content tr:nth-child(even) {
  background: #fff;
}
.content tr:nth-child(odd) {
  background: #f2f9ff;
}
.apply_expense {
  padding-bottom: 20px;
  font-family: '微软雅黑';
  font-weight: 800;
  text-align: center;
  margin:10px;
}
.expense-width {
  width: 60%;
}
.holder {
  text-align: center;
  margin: 20px 0 30px 0;
}
.editor {
  padding: 0 3% 0 16%;
}

</style>
<style>
.cell-width .el-input__count {
    background: transparent !important;
    position: absolute;
    font-size: 12px;
    bottom: -7px !important;
    right: 10px;
}
</style>